﻿#include "ssGLCheck.h"


ssOpenglCheck::ssOpenglCheck()
{
	m_manufacturer = 0;
	m_renderer = 0;
	m_gl = 0;
	m_glut = 0;
	m_glsl = 0;
	m_glew.clear();
}

ssOpenglCheck::~ssOpenglCheck()
{
}

void ssOpenglCheck::GetOpenglInfo()
{
	m_manufacturer = glGetString(GL_VENDOR);
	m_renderer = glGetString(GL_RENDERER);
	m_gl = glGetString(GL_VERSION);
	m_glsl = glGetString(GL_SHADING_LANGUAGE_VERSION);
#if !defined(SS_USE_GLES2) || defined(SS_USE_X11)
	m_glut = gluGetString(GLU_VERSION);
#endif
}

bool ssOpenglCheck::CheckGLSupport()
{
#if !defined(SS_USE_GLES2) || defined(SS_USE_X11)
	GLenum glewErr = glewInit();
	if (GLEW_OK != glewErr)
	{
		m_glew = "glew not Supported! ";
		m_glew += (const char*)glewGetErrorString(glewErr);
		return false;
	}
	if (!GLEW_VERSION_2_1)
	{
		m_glew = "gl2.1 not Supported! ";
		return false;
	}
	else
	{
		m_glew += "gl2.1 Supported, ";
	}
	if (!GLEW_VERSION_3_0)
	{
		m_glew = "gl3.0 not Supported! ";
		return false;
	}
	else
	{
		m_glew += "gl3.0 Supported, ";
	}
	if (!GLEW_ARB_vertex_shader)
	{
		m_glew = "vertex shader not Supported! ";
		return false;
	}
	else
	{
		m_glew += "vertex shader Supported, ";
	}
	if (!GLEW_ARB_fragment_shader)
	{
		m_glew = "piexl shader not Supported! ";
		return false;
	}
	else
	{
		m_glew += "piexl shader Supported, ";
	}
	if (!GLEW_ARB_vertex_buffer_object)
	{
		m_glew += "VBO not Supported, ";
	}
	else
	{
		m_glew += "VBO Supported, ";
	}
	if (!GLEW_ARB_vertex_array_object)
	{
		m_glew += "VAO not Supported, ";
	}
	else
	{
		m_glew += "VAO Supported, ";
	}
	//if (!GLEW_VERSION_3_1)
	//{
	//	m_glew += "gl3.1 not Supported, ";
	//}
	//else
	//{
	//	m_glew += "gl3.1 Supported, ";
	//}
	//if (!GLEW_VERSION_3_2)
	//{
	//	m_glew += "gl3.2 not Supported, ";
	//}
	//else
	//{
	//	m_glew += "gl3.2 Supported, ";
	//}
	//if (!GLEW_VERSION_3_3)
	//{
	//	m_glew += "gl3.3 not Supported, ";
	//}
	//else
	//{
	//	m_glew += "gl3.3 Supported, ";
	//}
	if (!GLEW_VERSION_4_0)
	{
		m_glew += "gl4.0 not Supported, ";
	}
	else
	{
		m_glew += "gl4.0 Supported, ";
	}
	if (!GL_ARB_point_sprite)
	{
		m_glew += "point sprite not Supported, ";
	}
	else
	{
		m_glew += "point sprite Supported";
	}
#endif
	return true;
}
